package nio.buffter;

import java.nio.ByteBuffer;
//类型
public class buffterTest2 {
    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        //存放
        byteBuffer.putChar('欧');
        byteBuffer.putLong(1000000000);
        byteBuffer.putShort((short) 1);
        //取
        byteBuffer.flip();//读写切换
        //System.out.println(byteBuffer.getChar());
        System.out.println(byteBuffer.getInt());//类型不对数据可能会发生改变
        System.out.println(byteBuffer.getInt());
        //System.out.println(byteBuffer.getLong()); //类型不对且无法隐式转换 会报错 BufferUnderflowException
        System.out.println(byteBuffer.getInt());
    }
}
